package uz.gov.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;

/**
 * Created with IntelliJ IDEA.
 * User: admin
 * Date: 02.04.14
 * Time: 20:23
 * To change this template use File | Settings | File Templates.
 */
public class HomePage extends BasePage {
    public HomePage(WebDriver driver) {
        super(driver);
    }


    public ResultPage search(String text){


        driver.findElement(searchBar).sendKeys(text);

        driver.findElement(saerchButton).click();

        //<button type="submit" class="btn-link-i">Найти</button>

            return new ResultPage(driver);

    }

    public  NavigationPage navigateTo(int menu_page_number){



        switch (menu_page_number){
            case 1:
                driver.findElement(computersNotebooks).click();
                break;
            case 2:
                driver.findElement(phonesMp3Gps).click();
                break;
            case 3:
                driver.findElement(tvPhotoVideo).click();
                break;
            case 4:
                driver.findElement(householdAppliances).click();
                break;
            case 5:
                driver.findElement(outdoorsMan).click();
                break;
            case 6:
                driver.findElement(kids).click();
                break;
            case 7:
                driver.findElement(houseGarden).click();
                break;
            case 8:
                driver.findElement(avto).click();
                break;
            case 9:
                driver.findElement(airTrainTickets).click();
                break;




            default:
                driver.findElement(mainPage).click();
                break;
        }

        return new  NavigationPage(driver);
    }


    public NavigationPage authorization(String email, String password){

        driver.findElement(By.name("signin")).click();
        driver.findElement(By.name("login"));
        driver.findElement(By.name("login")).clear();
        driver.findElement(By.name("login")).sendKeys(email);
        //Assert.assertEquals(email, driver.findElement(By.name("login")).getAttribute("value"));

        driver.findElement(By.name("password"));
        driver.findElement(By.name("password")).clear();
        driver.findElement(By.name("password")).sendKeys(password);



        driver.findElement(By.name("password")).sendKeys(Keys.ENTER);

        //driver.findElement(By.xpath("//*[@id=\"user-popup-parent95944\"]/div/div/div/form/div[4]/button")).click();

        driver.findElement(By.name("profile")).click();

        return new NavigationPage(driver);
    }

    public NavigationPage authorizationNegative(String email, String password){

        driver.findElement(By.name("signin")).click();
        driver.findElement(By.name("login"));
        driver.findElement(By.name("login")).clear();
        driver.findElement(By.name("login")).sendKeys(email);
        //Assert.assertEquals(email, inputElement1.getAttribute("value"));

        driver.findElement(By.name("password"));
        driver.findElement(By.name("password")).clear();
        driver.findElement(By.name("password")).sendKeys(password);



        driver.findElement(By.name("password")).sendKeys(Keys.ENTER);

        //driver.findElement(By.xpath("//*[@id=\"user-popup-parent95944\"]/div/div/div/form/div[4]/button")).click();

        //driver.findElement(By.name("profile")).click();

        return new NavigationPage(driver);
    }




















}
